package org.liaohailong.library.image.victor;

import android.graphics.Bitmap;
import android.util.LruCache;

/**
 * E-mail: liaohailong190@foxmail.com
 * Date: 2019/7/18 14:42
 * Description: Bitmap内存缓存
 *
 * @author liaohailong
 */
public class BitmapLruCache extends LruCache<String, Bitmap> {

    BitmapLruCache() {
        // 八分之一运行内存，单位Kb
        super((int) (Runtime.getRuntime().maxMemory() / 1024) / 8);
    }

    @Override
    protected int sizeOf(String key, Bitmap value) {
        return value.getRowBytes() * value.getHeight() / 1024;
    }
}
